﻿using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AutoCadConvert
{
    public class Collection:BspObject
    {
        public House m_house;
        public List<BspObject> m_EntityList = new List<BspObject>();
        private List<string> erMessageLst = new List<string>();
        public Collection(House house)
        {
            m_house = house;
        }
        public IEnumerable<Group> GetGroups()
        {
            using (Transaction tr = DwgConvert.Doc.Database.TransactionManager.StartTransaction())
            {
                DBDictionary groups = tr.GetObject(DwgConvert.Doc.Database.GroupDictionaryId,OpenMode.ForRead) as DBDictionary;
                foreach (DBDictionaryEntry entry in groups)
                    yield return tr.GetObject(entry.Value, OpenMode.ForRead) as Group;
            }
        }
        public override void AddData(Entity value)
        {
            if (value is Autodesk.AutoCAD.DatabaseServices.Line)
            {
                m_EntityList.Add(new Line(value as Autodesk.AutoCAD.DatabaseServices.Line));
            }
            else if (value is Autodesk.AutoCAD.DatabaseServices.Polyline)
            {
                m_EntityList.Add(new Line(value as Autodesk.AutoCAD.DatabaseServices.Polyline));
            }
            else if (value is Autodesk.AutoCAD.DatabaseServices.Hatch)
            {
            }
            else if (value is Autodesk.AutoCAD.DatabaseServices.DBPoint)
            {
            }
            else if (value is Autodesk.AutoCAD.DatabaseServices.AlignedDimension)
            {
                Autodesk.AutoCAD.DatabaseServices.AlignedDimension entity = value as Autodesk.AutoCAD.DatabaseServices.AlignedDimension;
                //double distance = entity.Measurement;
            }
            else if (value is Autodesk.AutoCAD.DatabaseServices.BlockReference)
            {//读取块属性
                m_EntityList.Add(new Block(value as Autodesk.AutoCAD.DatabaseServices.BlockReference));
            }
            else if (value is Autodesk.AutoCAD.DatabaseServices.MText)
            {
            }
            else if (value is Autodesk.AutoCAD.DatabaseServices.DBText)
            {
            }
            else if(value is Autodesk.AutoCAD.DatabaseServices.Circle)
            {
            }
            else if (value is Autodesk.AutoCAD.DatabaseServices.Ellipse)
            {
            }
            else if (value is Autodesk.AutoCAD.DatabaseServices.Spline)
            {
            }
            else if (value is Autodesk.AutoCAD.DatabaseServices.Xline)
            {//构造线
            }
            else if (value is Autodesk.AutoCAD.DatabaseServices.Arc)
            {//构造线
            }
            else
            {
                System.Diagnostics.Trace.WriteLine(this.GetType().Name + "____________________" + value.GetType().FullName);
            }
        }
    }
}
